package com.suep.data_analysis.controller;

import com.suep.data_analysis.dto.TeamRecommendationDto;
import com.suep.data_analysis.service.TeamRecommendationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/api/team-recommendations")
@AllArgsConstructor
public class TeamRecommendationController {
    private final TeamRecommendationService teamRecommendationService;

    @Operation(
            summary = "获取配队推荐",
            description = "根据指定代理人ID获取所有可能的配队推荐，按匹配分数排序",
            responses = {
                    @ApiResponse(responseCode = "200", description = "成功获取配队推荐"),
                    @ApiResponse(responseCode = "404", description = "代理人不存在")
            }
    )
    @GetMapping("/{agentId}")
    public ResponseEntity<List<TeamRecommendationDto>> getTeamRecommendations(
            @Parameter(description = "代理人ID") @PathVariable String agentId) {
        List<TeamRecommendationDto> recommendations = teamRecommendationService.recommendTeam(agentId);
        if (recommendations.isEmpty()) {
            return ResponseEntity.notFound().build();
        }
        return ResponseEntity.ok(recommendations);
    }
} 